home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
comm
/
tlx_sq21.zip
/
GRABMAIL.SLT
< prev
next >
Wrap
Text File
|
1992-03-20
|
18KB
|
539 lines
//-----------------------------------------------------------
// GrabMail.SL? Telix script to fetch mail from a BBS.
//
// Please look at the comments through the whole file, and modify to
// suit your needs, BEFORE you use it. Then recompile with CS GrabMail.
//-----------------------------------------------------------
// If you have suggestions for improving this script, please suggest
// improvements to me via old-fashioned snail-mail to:
// Author: Inge Vabekk
// Hamangskogen 108
// N-1300 SANDVIKA
// NORWAY
// tel. (472) 546 396
str command [10]="Command:" // Command prompt.
,input [80] // One input line.
,f0 [14] // Filename for download.
,maildir [64] // Mail directory or download directory.
,myprot [2] // My protocol
,hisprot [2] // PCB's protocol
// For the Global storage:
,global []="GLOBAL" // Global script.
,UpDownF []="UPDOWNF" // Get/Put File script.
,PutLine []="PUTLINE" // PutLine script.
,bbstype []="BTYPE" // BBS type.
,short []="SHORT" // Short BBS name.
,Cprot []="CPROT" // Current protocol.
,Hprot []="HPROT" // "His" protocol.
,version []="BBSver" // PCB version
,mdir []="MDIR" // Mail directory.
,rmode []="RMODE" // Read mode for MBBS
,prompt []="PROMPT" // Current command prompt.
;
int tol = 900 // No activity for 90 seconds
,tmark // makes script time out.
,stat // For tracking.
,BBSver // PCBoard version.
,MORE // More messages if TRUE.
,pcb, mbbs, rbbs, opus, fido, crcs // different kinds of systems
,protocol // Current protocol.
,file // File handle
,Enter=13 // Code for CR (Enter)
;
//-----------------------------------------------------------
// GrabMail script is entered here.
//-----------------------------------------------------------
main()
{
int i;
// This script is assumed to be called ONLY after logon
// to perform routine tasks.
// Only if online.
if (!carrier())
{ failtone();
status_wind ("T²: YOU CAN'T FETCH MAIL IF YOU'RE OFFLINE!",20);
return (-1);
}
entry(); // Updates status bar.
// Check which BBS system.
read (bbstype,input);
mbbs = pcb = rbbs = opus = fido = crcs = 0;
if (input == "MBBS") mbbs = 1;
else if (input == "PCB" ) pcb = 1;
else if (input == "RBBS") rbbs = 1;
else if (input == "OPUS") opus = 1;
else if (input == "FIDO") fido = 1;
else if (input == "CRCS") crcs = 1;
else
{ wrongBBS(input); // Doesn't match script!
return (-1);
}
read (prompt,command); // Get command prompt.
read (version,input);
BBSver = subchr (input,0); // Get PCBoard version.
read (cprot,myprot); // Get protocol.
protocol = subchr (myprot,0); // Must be INT.
read (hprot,hisprot);
read (mdir,maildir); // Get mail directory.
input = maildir; // Check it out.
strcat (input,"NPU.TMP"); // Try to create a file there.
if ((i=fopen(input,"w")) > 0)
{ fclose (i);
fdelete (input);
}
else
{ prints ("");
printsc ("T²: Wrong MAIL directory: ");
printsc (maildir);
prints ("! Can't grab messages!");
return (0);
}
// ZIPM or GRAB messages.
//-----------------------------------------------------------
MORE = 1;
while (MORE)
{ f0 = ""; // No name yet.
if (mbbs)
grab();
else if (pcb)
{ if (BBSver < 145)
zipm();
else
raz(); // PCBoard 14.5 and later
}
}
return (0);
}
//-----------------------------------------------------------
// This routine GRABS messages from MBBS.
//-----------------------------------------------------------
grab()
{
str filename[]="ilename: "; // Look for this text.
int t1, t2, t3, t4, mm, nm1, nm2, mess;
if (read (rmode,hisprot) < 0)
hisprot = "M"; // Get read mode.
input = "R MODE ";
strcat (input,hisprot);
strcat (input,";D A");
call (PutLine,input, Enter); // Read and dump all messages.
MORE = 0; // Donit.
mess = 1; // Assume messages.
t1 = track ("command!", 0); // Define new tracks.
t2 = track (command, 0); // Next command.
t3 = track ("on disk!", 0); // Not enough space for GRAB.
t4 = track ("Dumping ", 0); // Still dumping....
nm1 = track ("<0> messa", 0); // No messages.
nm2 = track ("<0> new m", 0); // No new messages.
mm = track ("More Messages", 0); // More messages.
tmark = timer_start (tol); // Give me a minute.
while ((stat=trig()) > 0) // answer any questions
{ if (stat == t1) // Illegal command (line error!)
call (PutLine,"R MODE F D A", Enter); // Send a new command.
else if (stat == t2) // Next command.
break;
else if (stat == t3) // Disc is full - Can't GRAB.
{ mess = 0;
break;
}
else if (stat == t4) // Still dumping;
; // this just postpones timeout.
else if (stat==nm1 || stat==nm2) // No more messages.
{ mess = 0;
MORE = 0;
}
else if (stat == mm) // More messages next time.
MORE = 1;
}
release();
if (mess) // Messages to fetch:
{ call (PutLine,"SE", Enter);
if (waitfor (filename,60))
get_file(filename); // Get the file.
}
}
//-----------------------------------------------------------
// This routine fetches messages from PCBoard rev. >= 14.5.
//-----------------------------------------------------------
raz()
{
str filename[]="elected: "; // Look for this text.
int mm // More messages.
,messages // Messages to fetch if == 1.
,co // Command
,dot // More coming....
,ccm // Compressing captured mail
,ec1, ec2 // ENTER to continue
,ntd // Nothing to download.
,Def // Default protocol
;
MORE = 0; // Donit.
messages = -1; // Command not sent.
// Track the following:
co = track (command,0); // Back to command.
Def = track ("col Desired",0); // Default protocol....
ec1 = track (")=continue?",0); // Press ENTER.
ec2 = track ("o download?",0); // Press ENTER.
ccm = track ("ssing captu",0); // Compressing captured mail.
ntd = track ("- nothing t",0); // Nothing to download.
mm = track (" limit reac",0); // Max. limit reached.
dot = track ("Scan",0); // Signals that it's working.
file= track (filename,0); // Filename comes now.
tol = 1200;
input = "T ";
strcat (input,hisprot); // Set protocol. Not really necessary
call (PutLine, input, Enter); // every time, but we can't know
// when it would be.
do
{ tmark = timer_start (tol); // Set time-out.
while ((stat=trig()) > 0) // answer any questions.
{ if (stat == co) // Command?
{ if (messages < 0)
{ call (PutLine,"R A Z", Enter); // Send READ ALL, then ZIP.
continue;
}